<!-- Breadcrums -->
<div class="container">
	<ul id="breadcrumbs">
	<?php foreach ($breadcrumbs as $key => $breadcrumb) { ?>
	<?php if($key == 0) {  ?>
		<li><a href="<?php echo $breadcrumb['href']; ?>"><i class="icon-home"></i></a></li>
		<?php } else { ?>
		<li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
		<?php } ?>
		<?php } ?>
	</ul>
</div>
<!-- Breadcrum -->
<div class="container">
	<div id="main">
		<div class="row">
			<div class="span12">
				<div class="tabbable tabbable-bordered property-detail-listing">
					<div class="property property-detail">
						<div class="review">
							<div class="share"><!-- AddThis Button BEGIN -->
								<div class="addthis_default_style">
									<a class="addthis_button_facebook"></a> 
									<a class="addthis_button_twitter"></a>
									<a class="addthis_button_email"></a>
									<a class="addthis_button_print"></a>
								</div>
								<script type="text/javascript"
									src="//s7.addthis.com/js/250/addthis_widget.js"></script> <!-- AddThis Button END -->
							</div>
						</div>
						<div class="clearfix"></div>
						<?php
						$listingtoview['media'] = $this->mdl_listingmapmodel->get_media($listingtoview['Listing_ID'], "Gallery", 20);
						?>
					
						<?php
						$preview = "";
						$thumb = "";
						if(isset($listingtoview['media']) && is_array($listingtoview['media']) && count($listingtoview['media']) > 0) {
							foreach ($listingtoview['media'] as $key => $img) {
								if ($key == 0) {
									$preview = $this->config->item('HTTP_LISTING_MEDIA_IMAGE') . $listingtoview['Listing_ID'] . '/' . str_replace(' ', '%20', $img->FileName . '-744x426' . $img->FileExtension);
									//get thumb for property map
									$thumb = $this->imagemodel->resize($img->FileName . $img->FileExtension, THUMB_IMAGE_WIDTH, THUMB_IMAGE_HEIGHT, HTTP_PROJECT_LISTING_IMAGE . $listingtoview['Listing_ID'] . '/', $this->config->item('HTTP_LISTING_MEDIA_IMAGE') . $listingtoview['Listing_ID'] . '/');
									break;
								}
							}
						}
						?> 
					
						<?php 
						$listingtoview['media'] = $this->mdl_listingmapmodel->get_media($listingtoview['Listing_ID'], "Gallery", 20);
						?>
						<?php if(isset($listingtoview['media']) && is_array($listingtoview['media']) && count($listingtoview['media']) > 0) { ?>
						<div class="row-fluid">
							<div class="span2"></div>
							<div class="span8">
								<h1 class="page-header page-header-listing-detail"><?php echo $listingtoview['ProjectName']; ?></h1>
								<div id="main-slider" class="flexslider" style="margin-bottom: 0px;">
								  	<ul class="slides">						  
										<?php foreach ($listingtoview['media'] as $key => $img) { ?>
										<li <?php if ($key == 0) { echo 'class="flex-active-slide"'; } ?>>
										<img src="<?php echo $this->config->item('HTTP_LISTING_MEDIA_IMAGE') . $listingtoview['Listing_ID'] . '/' . str_replace(' ', '%20', $img->FileName . '-744x426' . $img->FileExtension); ?>" alt="<?php echo $listingtoview['ProjectName']; ?>" />
										</li>
										<?php } ?>
									</ul>
								</div>
							</div>
							<div class="span2"></div>
						</div>
						<?php } ?>
						<!-- /.carousel -->						
					</div>
					<div class="property-detail properties-rows">
						<div class="row-fluid">
							<div class="span2"></div>
							<div class="span8">
								<div class="row-fluid">
									<div class="span4">
										<div class="row-fluid" id="contactAgent">
											<div class="widget-listing our-agents">
												<?php if($agentInfo) { ?>
												<div class="content">
													<div class="agent" style="border: 0px none; box-shadow:0 0 0 rgba(0, 0, 0, 0)">
														<!-- /.image -->
														<div class="name" style="text-align: left;"><strong><?php echo strtoupper($agentInfo['Name']); ?></strong></div>
														<!-- /.name -->
														<div class="phone">
															<img src="<?php echo $this->config->item('HTTP_IMAGE'); ?>icons/phone.png" alt="" />
															<strong><?php if(isset($agentInfo['Mobile'])){echo $agentInfo['Mobile'];} ?></strong>
														</div>
														<!-- /.phone -->
														<div class="email">
															<img src="<?php echo $this->config->item('HTTP_IMAGE'); ?>icons/email.png" alt="" />
															<a href="mailto:<?php if(isset($agentInfo['Email'])) { echo $agentInfo['Email'];} else {echo "agent@jllresidential.com";} ?>"><strong><?php if(isset($agentInfo['Email'])) { echo $agentInfo['Email'];} else {echo "agent@jllresidential.com";} ?></strong></a>
														</div>
														<!-- /.email -->
													</div>
												<!-- /.agent -->
												</div>
											<!-- /.content --> <?php } ?>
											</div>
											<div class="controls">
												<button type="submit" class="btn btn-primary btn-large contact-form" data-toggle="modal" data-target="#myModal">Contact</button>
											</div>
											<!-- /.our-agents -->
											<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
												<form action="" id="validate_field_contact_agent_detail_listing" class="button-contact-agent-detail-listing">
													<div class="modal-header">
													  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
													  <input type="hidden" name="agent_email" value="<?php echo $agentInfo['Email']; ?>" >
													  <input type="hidden" name="listing_id" value="<?php echo $listingtoview['Listing_ID']; ?>" >
													  <input type="hidden" name="listing_name" value="<?php echo $listingtoview['ProjectName']; ?>" >
														<input type="hidden" name="action" value="sendenquiry" />
													  <h3 id="myModalLabel">Contact this Agent</h3>
													  <div id="message_notification"></div>
													</div>
													<div class="modal-body">
														<div class="content">
															<div class="row-fluid">
													  			<div class="image span4">
													  				<?php if($agentInfo['AgentPhoto']) { ?>
																	<img src="<?php echo base_url(); ?>detail/getAgentProfilePhoto/<?php echo $agentInfo['Agent_ID'];?>" alt="<?php echo $agentInfo['Name']; ?>">
																	<?php } else { ?>
																	<img src="<?php echo $this->config->item('HTTP_AGENTS_MEDIA_IMAGE'); ?>no-image.png" alt="">
																	<?php } ?>
													  			</div>
													  			<div class="body span8">
													  				<h3><?php echo $agentInfo['Name']; ?></h3>
													  				<h5><a><?php echo $agentInfo['Mobile']; ?></a></h5>
													  				<h5><a href="mailto:<?php echo $agentInfo['Email']; ?>"><?php echo $agentInfo['Email']; ?></a></h5>
													  			</div>
													  		</div>
												  			<div class="row-fluid">
												  				<div class="span4">
												  					<input type="text" name="name" id="name" class="span12 agent_name" maxlength="20" value="Name">
												  				</div>
												  				<div class="span4">
												  					<input type="text" name="phone" id="phone" class="span12 agent_phone" maxlength="20" value="Phone">
												  				</div>
												  				<div class="span4">
												  					<input type="text" name="email" id="email" class="span12 agent_email" value="Email">
												  				</div>
												  			</div>
												  			<div class="row-fluid">
												  				<textarea class="span12" name="agent_message" id="agent_message" cols="70" rows="3"><?php echo $agentInfo['Name']; ?>, I saw your on Indonesia website. I'd like to schedule a time for us to talk. Please reply to this email.</textarea>
												  			</div>
														</div>
													</div>
													<div class="modal-footer">
													  <input type="submit" value="Send" id="" class="btn btn-primary">
													</div>
												</form>
											</div>
										</div>
									</div>
									<div class="span8">
										<div class="w-box-content cnt_a" style="border: 0px none;">
											<p class="sepH_a"><strong>Details</strong></p>
											<div class="row-fluid">
												<ul class="span6">
													<li class="">
														<p class="sepH_a"><span class="lblproject"><?php echo $text_price; ?>: </span>
														<?php if($listingtoview['Price_Min'] > 0) { ?>
														<?php echo $listingtoview['PriceUnit'] . " " . number_format(($listingtoview['Price_Min']), 0, '.', ','); ?>
														<?php } else { ?>
														Price on Application
														<?php } ?>
														</p>
													</li>
													<li class="">
														<?php 
															//get Tenure Name by Id
														$tenureObj = $this->lookupmodel->getTenure($this->config->item('config_language_id'), $this->config->item('market'), $listingtoview['Listing_ID']);
														$tenureName = isset($tenureObj->Name) ? $tenureObj->Name : "";
														?>
														<p class="sepH_a"><span class="lblproject"><?php echo $text_propertytype; ?>: </span>
														<?php echo $listingtoview['PropertyType'] ?>
														</p>
													</li>
													<li class="">
														<p class="sepH_a"><span class="lblproject"><?php echo $text_tenure; ?>: </span>
														<?php echo $tenureName; ?>
														</p>
													</li>
												</ul>
												<ul class="span6">
													<li class="">
														<div class="row-fluid">
															<?php
																//$price_usd = $listingtoview['Price_Min'] * IDR_TO_USD;
																//$price_usd_formatted = USD_UNIT . " " . number_format(($listingtoview['Price_Min'] * IDR_TO_USD), 0, '.', ',');
																//$price_converted_int = $this->helpermodel->price_converttobase(trim($listingtoview['Price_Min']), USD_UNIT);
																
																$rate = $this->helpermodel->getRateByUnitCurrency($listingtoview['PriceUnit']);	
																$price_usd = $listingtoview['Price_Min'] / $rate;
																$price_usd_formatted = USD_UNIT . " " . number_format(($listingtoview['Price_Min'] / $rate), 0, '.', ',')
															?>
															<?php if(!empty($listingtoview['Price_Min']) && $listingtoview['Price_Min'] > 0) { ?>
															<div class="pull-left span8 spanusd sepH_a">
																Estimated <?php echo $price_usd_formatted; ?>
															</div>
															<div class="pull-right span4">
																<select name="curencyid" class="curencyid_ajax span12" style="margin-bottom: 0px;">
																	<option value="AUD">AUD</option>
																	<option value="CNY">CNY</option>
																	<option value="EUR">EUR</option>
																	<option value="GBP">GBP</option>
																	<option value="HKD">HKD</option>
																	<option value="IDR">IDR</option>
																	<option value="INR">INR</option>
																	<option value="JPY">JPY</option>
																	<option value="NZD">NZD</option>
																	<option value="SGD">SGD</option>
																	<option value="THB">THB</option>
																	<option value="USD" selected="selected">USD</option>
																	<option value="VND">VND</option>
																</select>
															</div>
															<span class="price asking_price_local_int" style="visibility: hidden;with:0px;height: 0px;position: absolute">
																<?php echo $listingtoview['PriceUnit'] . " " . number_format(($listingtoview['Price_Min']), 0, '.', ','); ?>
										                    </span>
															<span class="price_usd" style="visibility: hidden;with:0px;height: 0px;position: absolute"><?php echo trim($price_usd); ?>
										                   	</span>
										                   	<span class="unit_price" style="visibility: hidden;with:0px;height: 0px;position: absolute"><?php echo $listingtoview['PriceUnit']; ?></span>
										                   	<?php } ?>
														</div>
													</li>
													<li class="">
														<p class="sepH_a"><span class="lblproject"><?php echo $text_size_default; ?>: </span>
														<?php if($listingtoview['ListingType'] == "land" && isset($listingtoview['LandArea']) && $listingtoview['LandArea'] > 0) { ?>
														<?php echo number_format($listingtoview['LandArea']) . ' ' . $listingtoview['SizeUnit']; ?>
														<?php } else { ?>
														<?php echo number_format($listingtoview['Size_Min']) . ' ' . $listingtoview['SizeUnit']; ?>
														<?php } ?>
														</p>
													</li>
													<li>
														<div class="span8 properties-rows">
															<div class="control-group property" style="margin-bottom: 0px;">
																<div class="controls">
																	<div class="bedrooms bedrooms_result sepH_b">
																		<div class="content"><?php echo $listingtoview['Bedroom']; ?></div>
																	</div>
																	<div class="bathrooms bathrooms_result sepH_b">
																		<div class="content"><?php echo $listingtoview['Bathroom']; ?></div>
																	</div>
																</div>
															</div>
												 		</div>
													</li>
												</ul>
											</div>
										</div>
									</div>
								</div>
							</div>
							<div class="span2"></div>
						</div>
						<div class="row-fluid">
						<div class="span2"></div>
						<div class="span8">
							<div class="row-fluid">
								<div class="clearfix"></div>
								<div class="w-box-content-2">
									<div class="jll-box-header">
										<h3 class="infohead"><?php echo $text_overview; ?></h3>
									</div>
									<div class="description">
										<?php echo html_entity_decode($listingtoview['Description'], ENT_QUOTES, 'UTF-8'); ?>
									</div>
									<div class="clearfix"></div>
									<?php if($features && $Facilities) { ?>
									<div class="row-fluid">
										<div class="span4">
											<div class="jll-box-header">
												<h3 class="infohead"><?php echo $text_features; ?></h3>
											</div>
											<ul class="span4">
											<?php foreach ($features as $feature) { ?>
												<li class="checked"><?php echo $feature['Name']; ?></li>
												<?php } ?>
											</ul>
										</div>
										<div class="span6">
											<div class="jll-box-header">
												<h3 class="infohead"><?php echo $text_facilities; ?></h3>
											</div>
											<ul class="span8">
											<?php foreach ($Facilities as $facility) { ?>
												<li class="checked"><?php echo $facility['Name']; ?></li>
												<?php } ?>
											</ul>
										</div>
									</div>
									<?php } else { ?>
									<?php if($features) { ?>
									<div class="row-fluid">
										<div class="span4">
											<div class="jll-box-header">
												<h3 class="infohead"><?php echo $text_features; ?></h3>
											</div>
											<ul class="span4">
											<?php foreach ($features as $feature) { ?>
												<li class="checked"><?php echo $feature['Name']; ?></li>
												<?php } ?>
											</ul>
										</div>
									</div>
									<?php } ?>
									<?php if($Facilities) { ?>
									<div class="row-fluid">
										<div class="span6">
											<div class="jll-box-header">
												<h3 class="infohead"><?php echo $text_facilities; ?></h3>
											</div>
											<ul class="span8">
											<?php foreach ($Facilities as $facility) { ?>
												<li class="checked"><?php echo $facility['Name']; ?></li>
												<?php } ?>
											</ul>
										</div>
									</div>
									<?php } ?>
									<?php } ?> 
								</div>
							</div>
						</div>
						<div class="span2"></div>
					</div>
					<div class="formSep">
						<div class="row-fluid">
							<div class="span2"></div>
							<div class="span8">
								<?php if(isset($disclaimer->Content) && !empty($disclaimer->Content) && strlen($disclaimer->Content) > 8) { ?>
								<div class="w-box-content-2 disclaimer">
									<?php echo html_entity_decode($disclaimer->Content, ENT_QUOTES, 'UTF-8'); ?>
								</div>
								<?php } ?>
								<div class="property-detail">
									<h3 class="infohead">Map</h3>
									<input type="hidden" id="latListing" value="<?php echo $listingtoview['Latitude']; ?>" /> 
									<input type="hidden" id="lngListing" value="<?php echo $listingtoview['Longitude']; ?>" />
									<input type="hidden" id="priceListing" value="<?php if($listingtoview['Price_Min'] > 0) { ?> <?php echo $listingtoview['PriceUnit'] . " " . number_format(($listingtoview['Price_Min']), 0, '.', ','); ?> <?php } else { ?> <?php echo "Price On Application"; ?> <?php } ?>" />
									<input type="hidden" id="areaListing" value="<?php echo number_format($listingtoview['Size_Min']) . ' ' . $listingtoview['SizeUnit']; ?>" />
									<input type="hidden" id="thumbListing" value="<?php echo $thumb; ?>" />
									<input type="hidden" id="titleListing" value="<?php echo $listingtoview['ProjectName']; ?>" />
									<div id="property-map"></div>
								<!-- /#property-map -->
								</div>
							</div>
							<div class="span2"></div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<?php //$this->load->view('helpers/widgets/contact.php'); ?> 
		</div>
	</div>
</div>
